/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "WaterSalts")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "WaterSalts.findAll", query = "SELECT w FROM WaterSalts w"),
    @NamedQuery(name = "WaterSalts.findBySaltID", query = "SELECT w FROM WaterSalts w WHERE w.saltID = :saltID"),
    @NamedQuery(name = "WaterSalts.findBySciName", query = "SELECT w FROM WaterSalts w WHERE w.sciName = :sciName"),
    @NamedQuery(name = "WaterSalts.findByCommonName", query = "SELECT w FROM WaterSalts w WHERE w.commonName = :commonName"),
    @NamedQuery(name = "WaterSalts.findByCa", query = "SELECT w FROM WaterSalts w WHERE w.ca = :ca"),
    @NamedQuery(name = "WaterSalts.findByCl", query = "SELECT w FROM WaterSalts w WHERE w.cl = :cl"),
    @NamedQuery(name = "WaterSalts.findByCo3", query = "SELECT w FROM WaterSalts w WHERE w.co3 = :co3"),
    @NamedQuery(name = "WaterSalts.findByNa", query = "SELECT w FROM WaterSalts w WHERE w.na = :na"),
    @NamedQuery(name = "WaterSalts.findBySo4", query = "SELECT w FROM WaterSalts w WHERE w.so4 = :so4"),
    @NamedQuery(name = "WaterSalts.findByMolecularName", query = "SELECT w FROM WaterSalts w WHERE w.molecularName = :molecularName"),
    @NamedQuery(name = "WaterSalts.findByMg", query = "SELECT w FROM WaterSalts w WHERE w.mg = :mg")})
public class WaterSalts implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "saltID")
    private Integer saltID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "sciName")
    private String sciName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "commonName")
    private String commonName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Ca")
    private float ca;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Cl")
    private float cl;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CO3")
    private float co3;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Na")
    private float na;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SO4")
    private float so4;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "molecularName")
    private String molecularName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Mg")
    private float mg;
    @JoinColumn(name = "invItem", referencedColumnName = "SupID", nullable=true)
    @ManyToOne(optional = true)
    private Supplies supID;
    @OneToMany(mappedBy = "waterSaltID")
    private Collection<SelectedSalt> selectedSaltCollection;
    @OneToMany(mappedBy = "waterSaltID")
    private Collection<SelectedSalt> saltNoteCollection;

    public WaterSalts() {
    }

    public WaterSalts(Integer saltID) {
        this.saltID = saltID;
    }

    public WaterSalts(Integer saltID, String sciName, String commonName, float ca, float cl, float co3, float na, float so4, String molecularName, float mg) {
        this.saltID = saltID;
        this.sciName = sciName;
        this.commonName = commonName;
        this.ca = ca;
        this.cl = cl;
        this.co3 = co3;
        this.na = na;
        this.so4 = so4;
        this.molecularName = molecularName;
        this.mg = mg;
    }

    public Integer getSaltID() {
        return saltID;
    }

    public void setSaltID(Integer saltID) {
        this.saltID = saltID;
    }

    public String getSciName() {
        return sciName;
    }

    public void setSciName(String sciName) {
        this.sciName = sciName;
    }

    public String getCommonName() {
        return commonName;
    }

    public void setCommonName(String commonName) {
        this.commonName = commonName;
    }

    public float getCa() {
        return ca;
    }

    public void setCa(float ca) {
        this.ca = ca;
    }

    public float getCl() {
        return cl;
    }

    public void setCl(float cl) {
        this.cl = cl;
    }

    public float getCo3() {
        return co3;
    }

    public void setCo3(float co3) {
        this.co3 = co3;
    }

    public float getNa() {
        return na;
    }

    public void setNa(float na) {
        this.na = na;
    }

    public float getSo4() {
        return so4;
    }

    public void setSo4(float so4) {
        this.so4 = so4;
    }

    public String getMolecularName() {
        return molecularName;
    }

    public void setMolecularName(String molecularName) {
        this.molecularName = molecularName;
    }

    public float getMg() {
        return mg;
    }

    public void setMg(float mg) {
        this.mg = mg;
    }

    public Supplies getSupID() {
        return supID;
    }

    public void setSupID(Supplies supID) {
        if(supID != null && supID.getSupID() != null){
            this.supID = supID;
        }
    }

    @XmlTransient
    public Collection<SelectedSalt> getSelectedSaltCollection() {
        return selectedSaltCollection;
    }

    public void setSelectedSaltCollection(Collection<SelectedSalt> selectedSaltCollection) {
        this.selectedSaltCollection = selectedSaltCollection;
    }

    @XmlTransient
    public Collection<SelectedSalt> getSaltNoteCollection() {
        return saltNoteCollection;
    }

    public void setSaltNoteCollection(Collection<SelectedSalt> saltNoteCollection) {
        this.saltNoteCollection = saltNoteCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (saltID != null ? saltID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof WaterSalts)) {
            return false;
        }
        WaterSalts other = (WaterSalts) object;
        if ((this.saltID == null && other.saltID != null) || (this.saltID != null && !this.saltID.equals(other.saltID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.WaterSalts[ saltID=" + saltID + " ]";
    }
    
}
